#ifndef COMMON_TOOLS_H_
#define COMMON_TOOLS_H_

#include <iostream>
#include <algorithm>

template<typename T>
void changeLength1D(T*& a, int oldLength, int newLength)
{
    if (newLength <0)
    {
        throw "new length must be >= 0";
    }

    T*  temp = new T[newLength]; // new vector
    int number = oldLength > newLength ? newLength : oldLength;
    std::copy(a, a + number, temp); 
    delete [] a; // delete old data
    
    a = temp;
}

#endif //COMMON_TOOLS_H_
